import { sm2 } from 'sm-crypto';
//公钥串---加密使用
const publicKey = "044291b381a039a8d7d02d7272d2d7c78a30d33e3eeaa0b509bf77d2376582ab2d573730e6bfe9a53bad53f53ac1a85d9c11050931f04bc8b3afc04144d5a6f9be"
//私钥串---解密使用
const privateKey = "5aa03412c3051e1d4cf9d19cfbeeec70c28f388c9f82747cc912096c9cd44bea"
// 加密方法
const JIAMIPublicData = (data:string): string => {
  const cipherMode = 1;
  const result = sm2.doEncrypt(data, publicKey, cipherMode);
  return `04${result}`;
}
// 解密方法
const JIMIPublicData = (data:string): string => {
  const cipherMode = 1;
  //data为加密的数据
  const result = sm2.doDecrypt(data, privateKey, cipherMode).split('04')[1]
  return result;
}
export{
  JIAMIPublicData,
  JIMIPublicData 
}